﻿using JustMetClient.Models.InfoModels;
using Azylee.Core.WindowsUtils.InfoUtils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JustMetClient.Utils.InfoUtils
{
    public static class HardwareInfoTool
    {
        public static HardwareInfoModel Get()
        {
            HardwareInfoModel info = new HardwareInfoModel();
            #region 获取CPU信息
            var cpu = ComputerInfoTool.CpuInfo();
            if (cpu != null) info.CPU = new CPUHardwareInfoModel() { Model = cpu.Item2 };
            #endregion
            #region 获取主板信息
            var board = ComputerInfoTool.BoardInfo();
            if (board != null) info.Board = new BoardHardwareInfoModel() { Model = board.Item2 };
            #endregion
            #region 获取硬盘信息
            var harddisk = ComputerInfoTool.HardDiskInfo();
            if (harddisk != null)
            {
                info.Drives = new List<DriveHardwareInfoModel>();
                for (int i = 0; i < harddisk.Count; i++)
                {
                    info.Drives.Add(new DriveHardwareInfoModel()
                    {
                        Model = harddisk[i].Item2
                    });
                }
            }
            #endregion
            #region 获取显卡信息
            var graphics = ComputerInfoTool.GraphicsCardInfo();
            if (graphics != null)
            {
                info.GraphicsCards = new List<GraphicsCardHardwareInfoModel>();
                for (int i = 0; i < graphics.Count; i++)
                {
                    info.GraphicsCards.Add(new GraphicsCardHardwareInfoModel()
                    {
                        Model = graphics[i].Item1
                    });
                }
            }
            #endregion
            #region 获取声卡信息
            var sound = ComputerInfoTool.SoundCardModel();
            if (sound != null)
            {
                info.SoundCard = new List<SoundCardHardwareInfoModel>();
                for (int i = 0; i < sound.Count; i++)
                {
                    info.SoundCard.Add(new SoundCardHardwareInfoModel()
                    {
                        Model = sound[i]
                    });
                }
            }
            #endregion
            #region 获取网卡信息
            var netcard = ComputerInfoTool.NetworkCardInfo();
            if (netcard != null)
            {
                info.NetworkCard = new List<NetworkCardHardwareInfoModel>();
                for (int i = 0; i < netcard.Count; i++)
                {
                    info.NetworkCard.Add(new NetworkCardHardwareInfoModel()
                    {
                        Name = netcard[i].Item1,
                        Desc = netcard[i].Item2,
                        MAC = netcard[i].Item3,
                        IP = netcard[i].Item4,
                        Gateway = netcard[i].Item5,
                    });
                }
            }
            #endregion
            return info;
        }
    }
}
